/* eslint-disable react/display-name */
import React, { Suspense, lazy } from 'react';
import { RouteConfig } from 'react-router-config';
import Loading from '@components/loading';

// 延迟加载回调
const SuspenseComponent = (Component: any) => (props: any) => {
  return (
    <Suspense fallback={<Loading />}>
      <Component {...props}></Component>
    </Suspense>
  )
}

const AppPage = lazy(() => import('@pages/app'));
const AboutPage = lazy(() => import('@pages/about'));

const routes: RouteConfig[] = [
  {
    path: '/',
    exact: true,
    component: SuspenseComponent(AppPage)
  },
  {
    path: '/about',
    exact: true,
    component: SuspenseComponent(AboutPage)
  }
];

export default routes;
